<?php 
	include("event-config.php");

	if (!isset($_POST['event_id']) || !isset($_POST['username'])){
		header("Location: error.php");
	}
	else {
		$event_id = $_POST['event_id'];
		$username = $_POST['username'];
		$query = "UPDATE `event_join` SET `is_confirm`= NOT(`is_confirm`) 
				  WHERE `user_login` = '$username' AND `event_id` = '$event_id'";
		if (!execute($query)){
			echo "fail";
		}
		else {
			echo "success";
		}
	}
 ?>